/**
 * Created by Elsa on 2017/8/29.
 */
layui.define(['form','jquery'], function(exports){
    var form = layui.form(),
        $ = layui.jquery,
        layer = layui.layer;

    var rgstnum = getQueryString("rgstnum");
    console.log(rgstnum);

    $.ajax({
        type:"GET",
        url:contextPath+"/project/ops/lj/"+ rgstnum ,
        contentType: "application/json; charset=utf-8",
        dataType:"json",
        success:function (data) {
            console.log(data);
            $('input[name="shipname"]').attr("value",data.shipname);
            $('input[name="rgstnum"]').attr("value",data.rgstnum);

            if(data.ljdate){
                $('input[name="ljname"]').attr("value",data.ljname);
                $('input[name="ljdate"]').attr("value",data.ljdate);

                $('#span1').html(data.ljt1jg);
                $('input[name="ljt1jg"][value="'+data.ljt1jg+'"]').attr("checked",true);
                $('#span1x').html(data.ljt1bz);
                $('input[name="re1"]').attr("value",data.ljt1bz);

                $('#span2').html(data.ljt2jg);
                $('input[name="ljt2jg"][value="'+data.ljt2jg+'"]').attr("checked",true);
                $('#span2x').html(data.ljt2bz);
                $('input[name="re2"]').attr("value",data.ljt2bz);

                $('#span3').html(data.ljt3jg);
                $('input[name="ljt3jg"][value="'+data.ljt3jg+'"]').attr("checked",true);
                $('#span3x').html(data.ljt3bz);
                $('input[name="re3"]').attr("value",data.ljt3bz);

                $('#span4').html(data.ljt4jg);
                $('input[name="ljt4jg"][value="'+data.ljt4jg+'"]').attr("checked",true);
                $('#span4x').html(data.ljt4bz);
                $('input[name="re4"]').attr("value",data.ljt4bz);

                $('#span5').html(data.ljt5jg);
                $('input[name="ljt5jg"][value="'+data.ljt5jg+'"]').attr("checked",true);
                $('#span5x').html(data.ljt5bz);
                $('input[name="re5"]').attr("value",data.ljt5bz);

                $('#span6').html(data.ljt6jg);
                $('input[name="ljt6jg"][value="'+data.ljt6jg+'"]').attr("checked",true);
                $('#span6x').html(data.ljt6bz);
                $('input[name="re6"]').attr("value",data.ljt6bz);

                $('#span7').html(data.ljt7jg);
                $('input[name="ljt7jg"][value="'+data.ljt7jg+'"]').attr("checked",true);
                $('#span7x').html(data.ljt7bz);
                $('input[name="re7"]').attr("value",data.ljt7bz);

                $('#span8').html(data.ljt8jg);
                $('input[name="ljt8jg"][value="'+data.ljt8jg+'"]').attr("checked",true);
                $('#span8x').html(data.ljt8bz);
                $('input[name="re8"]').attr("value",data.ljt8bz);

                $('#span9').html(data.ljt9jg);
                $('input[name="ljt9jg"][value="'+data.ljt9jg+'"]').attr("checked",true);
                $('#span9x').html(data.ljt9bz);
                $('input[name="re9"]').attr("value",data.ljt9bz);

                $('#span10').html(data.ljt10jg);
                $('input[name="ljt10jg"][value="'+data.ljt10jg+'"]').attr("checked",true);
                $('#span10x').html(data.ljt10bz);
                $('input[name="re10"]').attr("value",data.ljt10bz);

                $('#span11').html(data.ljt11jg);
                $('input[name="ljt11jg"][value="'+data.ljt11jg+'"]').attr("checked",true);
                $('#span11x').html(data.ljt11bz);
                $('input[name="re11"]').attr("value",data.ljt11bz);

                $('#span12').html(data.ljt12jg);
                $('input[name="ljt12jg"][value="'+data.ljt12jg+'"]').attr("checked",true);
                $('#span12x').html(data.ljt12bz);
                $('input[name="re12"]').attr("value",data.ljt12bz);

                $('#sus').show();
                $('#su').on('click',function () {
                    window.open('../../../../print/opera/ExperRecord/lj/OperaLjRecord.html?rgstnum='+rgstnum);
                });

            }else{

            }

        },
        error:function (e) {

        }
    });

    form.render();

    //自定义验证规则
    form.verify({
        title: function(value) {
            if(value.length < 5) {
                return '标题至少得5个字符啊';
            }
        },
        pass: [/(.+){6,12}$/, '密码必须6到12位'],
        content: function(value) {
            layedit.sync(editIndex);
        }
    });

    exports('OperaLjRecord', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});